<?php if(!$this->student):?>
<h1><?php echo $this->translate("can't found student" )?></h1>
<?php else: ?>
<script>
$(document).ready(function(){

    $('#setForm').ajaxForm({
        success:       showResponse
        });
    function showResponse() {
        $("#student_id").trigger('change');
        jAlert('<?php echo $this->translate("completed")?>');
    }
});
</script>
<?php $studyCondition = Student_Model_Student::getStudentConditionArray()?>
<form method="post" id="setForm"
	action="<?php echo $this->route('set')?>">
	<input type="hidden" 	name="student_sn" value="<?php echo $this->student->sn?>" />
<table style="float: left">
	<tr>
		<th><?php echo $this->translate('student name')?></th>
		<td><?php echo $this->student->name?></td>
	</tr>
	<tr>
		<th><?php echo $this->translate('student study condition')?></th>
		<td><?php echo $studyCondition[$this->student->study_condition]?></td>
	</tr>
</table>
<div style="float: left; margin: 5px"><input type="submit"
	id="submitBtn" value="<?php echo $this->translate('submit')?>" /> <input
	type="reset" id="cancelBtn"
	value="<?php echo $this->translate('reset')?>" /></div>
<div style="clear: both"></div>
<table>
	<thead>
		<tr>
			<th><?php echo $this->translate('year')?></th>
			<th><?php echo $this->translate('semester')?></th>
			<th><?php echo $this->translate('class')?></th>
			<th><?php echo $this->translate('number')?></th>
		</tr>
	</thead>
	<tbody>
	<?php for($i = $this->low_year; $i <= $this->highYear; $i++):?>
	<?php
	$year = $this->student->enroll_year+$i-1;
	$classSn1 = $classSn2 = '';
	if (isset($this->studentSemester[$year.'-1'])) {
	    $classSn1 = $this->studentSemester[$year.'-1']['grade'].'-'.
	    $this->studentSemester[$year.'-1']['class_sn'];
	}
	if (isset($this->studentSemester[$year.'-2'])) {
	    $classSn2 = $this->studentSemester[$year.'-2']['grade'].'-'.
	    $this->studentSemester[$year.'-2']['class_sn'];
	}
	?>
		<tr>
			<td><?php echo $year?></td>
			<td>1</td>
			<td><?php $classOption = $this->ClassNameOptions($year.'-1-'.$i, $classSn1)?>
			<?php if ($classOption):?> <select
				name="yearSemester[<?php echo $year?>-1]">
				<?php echo $classOption?>
			</select> <?php else:?> <?php echo $this->translate('yet assign')?> <?php endif?>
			</td>
			<td><?php if ($classOption):?> <input type="text" size="3"
				name="number[<?php echo $year?>-1]"
				value="<?php if (isset($this->studentSemester[$year.'-1']['number'])) echo $this->studentSemester[$year.'-1']['number'];?>" />
				<?php endif?></td>
		</tr>
		<tr>
			<td><?php echo $year?></td>
			<td>2</td>
			<td><?php $classOption = $this->ClassNameOptions($year.'-2-'.$i, $classSn2)?>
			<?php if ($classOption):?> <select
				name="yearSemester[<?php echo $year?>-2]">
				<?php echo $classOption?>
			</select> <?php else:?> <?php echo $this->translate('yet assign')?> <?php endif?>
			</td>
			<td><?php if ($classOption):?> <input type="text" size="3"
				name="number[<?php echo $year?>-2]"
				value="<?php if(isset($this->studentSemester[$year.'-2']['number'])) echo  $this->studentSemester[$year.'-2']['number']?>" />
			<?php endif?></td>
		</tr>
		<?php endfor?>
	</tbody>
</table>
</form>
<?php endif;?>